<?php

class Zend_View_Helper_Breadcrumb extends Zend_View_Helper_Abstract
{
    
    public function breadcrumb($product = NULL)
    {
        
        if ($this->view->bread) {
            $bread = $this->view->bread;
            $crumbs = array();
            $bread = array_reverse($bread);
            
            foreach ($bread as $category) {
                $href = $this->view->url(
                            array('categoryIdent' => $category->ident,),
                            'catalog_category'
                        );
                $crumbs[] = '<a href="' . $href .  '">' .
                            $this->view->Escape($category->name) .
                            '</a>';
            }
            
            if (NULL !== $product){
                $crumbs[] = $this->view->Escape($product->name);
            }
            
            return join('&raquo', $crumbs);
            
        }
        
    }
    
}